/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.Shop.dao;

import com.Shop.beans.Document;

/**
 *
 * @author cjh
 */
public class DocumentDao extends BaseDao{

    /**
     *  从数据库中获取相应ID的文档
     * @param id
     * @return
     */
    public Document loadDocumentById(int id){
        String hql = "from Document where id = ?";
        return (Document) this.getSession().createQuery(hql).setParameter("id", id).uniqueResult();
    }
    
    /**
     *  往数据库里面写入一条上传记录
     * @param doc
     */
    public void addDocument(Document doc){
        this.getSession().save(doc);
    }
    public Document uploadMsg(String filename){
        String hql="from Document where filename=?";
        return (Document)this.getSession().createQuery(hql).setParameter(0,filename).uniqueResult();
    }
}
